﻿// <copyright file="Calculators.cs" company="Gravity Age Studios">
// Code released under the MIT license (see License.txt).
// </copyright>
// <author>Vicente Cartas Espinel</author>
// <email>vicente.cartas@gmail.com</email>
namespace LightSwitchApplication.Rules
{
    using System;

    public static class Calculators
    {
        private static DomainProvinceCalculator domainProvinceCalculator = new DomainProvinceCalculator();

        public static DomainProvinceCalculator DomainProvinceCalculator
        {
            get
            {
                return domainProvinceCalculator;
            }
        }
    }

    public class DomainProvinceCalculator
    {
        public int CalculateMagicLevel(DomainProvince province)
        {
            if (province.Race != null)
            {
                if (province.Race.Name.Equals("Elf", StringComparison.InvariantCultureIgnoreCase))
                {
                    return province.BaseProvince.Terrain.MaximumMagic;
                }
            }

            return Math.Max(0, (province.BaseProvince.Terrain.MaximumMagic - province.PopulationLevel));
        }
    }
}
